﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpenseSystem.Common;
using ExpenseSystem.Common.BaseModel;
using ExpenseSystem.DataUpdater;
using ExpenseSystem.Fether;
using ExpenseSystem.Model;
using ExpenseSystem.Core.DataAddOn;
using System.Web;

namespace ExpenseSystem.Core.ProductionModules
{
    public class UnitManager : INormalManager<UnitModel>
    {
        protected string tran = HttpContext.Current.Items[Definition.SESSION_TRAN_STR].ToString();
        UnitFetcher fetcher = new UnitFetcher();
        protected NormalDataUpdater<UnitModel> UnitUpdater = new UnitUpdaterRegister().GetUnitUpdater();
        protected UserProfile userProfile = Authority.Authority.GetUserProfile();
        public virtual bool Delete(UnitModel role, out string message)
        {
            bool result = UnitUpdater.Remove(role, tran, fetcher, out message);
            return result;
        }
        public virtual bool DeleteById( long[] UnitId,  out string message)
        {
            bool result = true;
            result = UnitUpdater.RemoveById(userProfile.SiteId, UnitId, tran, fetcher, out message);
            return result;
        }
        public virtual bool Save(UnitModel Unit, out string message, params IAddable<UnitModel>[] addables)
        {
            return UnitUpdater.Save(Unit, tran, fetcher, out message);
        }

    }
}
